package com.day10.test4_jdk_date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @author 小坡
 * @date 2022/9/13  22:11
 **/
public class TestJDKDate {
    public static void main(String[] args) throws ParseException {

//        JDK8Method();
        String s = "2022年11月11日 00:00:00";
        DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");
        LocalDateTime localDateTime = LocalDateTime.parse(s, pattern);
        LocalDateTime newlocalDateTime = localDateTime.plusDays(1);
        String result = newlocalDateTime.format(pattern);
        System.out.println(result);


    }

    private static void JDK8Method() throws ParseException {
        String s = "2022年11月11日 00:00:00";
        SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
        Date date = simpleDateFormat1.parse(s);
        long time = date.getTime();
        time = time + (1000 * 60 * 60 * 24);
        Date newdate = new Date(time);
        String result = simpleDateFormat1.format(newdate);
        System.out.println(result);
    }
}
